﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Mappings;

namespace Apollo
{
    [NHibernateEntity(Table = "Employees", Lazy = true)]
    public class Employee : ITrackable, ILegacy, IStateable, IPositionable
    {
        public Employee() { }

        [PrimaryKey]
        public virtual int Id { get; set; }

        [Property]
        public virtual string InternalCode { get; set; }

        [Property]
        public virtual string OxyCode { get; set; }

        [Property]
        public virtual string Code { get; set; }

        [Property]
        public virtual string FirstName { get; set; }

        [Property]
        public virtual string LastName { get; set; }


        [Property(Formula = "(FirstName + ' ' + LastName)")]
        public virtual string FullName { get; set; }


        [Property]
        public virtual EmployeeType EmployeeType { get; set; }


        [Property]
        public virtual string Phone { get; set; }

        [Property]
        public virtual string Phone2 { get; set; }

        [Property]
        public virtual string Mobile { get; set; }

        [Property]
        public virtual string Mail { get; set; }



        [Property]
        public virtual State State { get; set; }

        [Property]
        public virtual DateTime HireDate { get; set; }

        [Property]
        public virtual DateTime StartDate { get; set; }

        [Property]
        public virtual DateTime? EndDate { get; set; }


        [BelongsTo(Column = "ID_Office")]
        public virtual Office Office { get; set; }

        [BelongsTo(Column = "ID_ReportsTo_Employee")]
        public virtual Employee ReportsTo { get; set; }

        [BelongsTo(Column = "ID_Position")]
        public virtual Position Position { get; set; }

        [BelongsTo(Column = "ID_Role")]
        public virtual Role Role { get; set; }


        [Property]
        public virtual string LegacyApplication { get; set; }

        [Property]
        public virtual string LegacyID { get; set; }



        [Property]
        public virtual DateTime InsertDate { get; set; }

        [Property]
        public virtual string InsertBy { get; set; }

        [Property]
        public virtual DateTime? ModifiedDate { get; set; }

        [Property]
        public virtual string ModifiedBy { get; set; }


        [Property(Column = "calculation_month")]
        public virtual int? CalculationMonth { get; set; }

        [Property(Column = "calculation_msg")]
        public virtual string CalculationMessage { get; set; }

        #region Commissioning used properties
        [Property]
        public virtual double QuarantyGrossValue { get; set; }
        
        [Property]
        public virtual double QuarantyMaxValue { get; set; }

        [Property]
        public virtual double FCGGrossValue { get; set; }

        [Property]
        public virtual double NCFGrossValue { get; set; }

        [Property]
        public virtual int? ID_Last_CommissionCalculation { get; set; }

        [Property]
        public virtual double SFACoefficient { get; set; }

        [Property]
        public virtual double SFAQuarterCoefficient { get; set; }
        
        [Property]
        public virtual double ProductivityCoefficient { get; set; }
        #endregion


        [BelongsTo(Column = "ID_ReappointedSource_Employee")]
        public virtual Employee ReappointedSource { get; set; }

        [BelongsTo(Column = "ID_Recruiter_Employee")]
        public virtual Employee Recruiter { get; set; }


        [Property]
        public virtual int? ID_CSC { get; set; }


        #region Salary used properties
        [Property]
        public virtual string BankName { get; set; }

        [Property]
        public virtual string BankIBAN { get; set; }

        [Property]
        public virtual double BaseIncomeValue { get; set; }
        #endregion


        [BelongsTo(Column = "ID_Address")]
        public virtual Address Address { get; set; }

        #region Accounting fields
        //[Property]
        //public virtual DateTime? ContractStartDate { get; set; }

        //[Property]
        //public virtual DateTime? ContractEndDate { get; set; }

        //[Property]
        //public virtual EmployeeState ContractState { get; set; }
        #endregion
    }

    public enum EmployeeType
    {
        Undefined = 0,
        Agent = 1,
        Company = 2,
    }

    public enum EmployeeState 
    { 
        Inactive = 0,
        Active = 1,
    }
}
